package com.jk.util;

import org.apache.solr.client.solrj.impl.HttpSolrClient;

public class SolrClient {
    //连接关键
    private static HttpSolrClient solrClient = null;

    private static String url="http://localhost:8082/solr/shordemo2";

    public  static HttpSolrClient getSolrClient(){

        if (solrClient==null){
            solrClient = new HttpSolrClient(url);
            solrClient.setDefaultMaxConnectionsPerHost(1000);
            solrClient.setMaxTotalConnections(10000);
            solrClient.setConnectionTimeout(60000);//设置连接超时时间（单位毫秒） 1000
            solrClient.setSoTimeout(60000);//// 设置读数据超时时间(单位毫秒) 1000
            solrClient.setFollowRedirects(false);//遵循从定向
            solrClient.setAllowCompression(true);//允许压缩

        }


        return solrClient;
    }

}
